// run: $exec < input
#include <iostream>
#include <vector>
#include <queue>

int const inf = 1 << 28;
int const maxn = 200;
using matrix_type = std::vector<std::vector<bool>>;

struct Matrix
{
	matrix_type a;
	int n, m;
	Matrix(matrix_type const & a, int n, int m) : a(a), n(n), m(m) {}
	Matrix(int n, int m) : n(n), m(m)
	{
		a.resize(n);
		for (int i = 0; i < n; i++) a[i].resize(m);
	}
};

Matrix operator*(Matrix const & a, Matrix const & b)
{
	Matrix ret(a.n, b.m);
	for (int i = 0; i < a.n; i++)
		for (int j = 0; j < b.m; j++)
			for (int k = 0; k < a.m; k++)
				ret.a[i][j] = (ret.a[i][j] | (a.a[i][k] & b.a[k][j]));
	return ret;
}

Matrix & operator|=(Matrix & a, Matrix const & b)
{
	for (int i = 0; i < a.n; i++)
		for (int j = 0; j < a.m; j++) a.a[i][j] = a.a[i][j] | b.a[i][j];
	return a;
}

Matrix quick(Matrix const & a, int b)
{
	Matrix ret(a.n, a.n);
	if (b == 0) return ret;
	if (b == 1) return a;
	Matrix tmp = quick(a, b/2);
	tmp = tmp * tmp;
	if (b & 1) tmp = tmp * a;
	return tmp;
}

bool map[maxn][maxn];
bool vis[maxn];
int dis[maxn];
int indegree[maxn];
int n, m, a, b, c;

bool judge_circle(int u)
{
	vis[u] = true;
	for (int i = 0; i < n; i++) {
		if (i == u || i == n - 1 || !map[u][i]) continue;
		if (vis[i]) return true;
		if (judge_circle(i)) return true;
	}
	return false;
}

int main()
{
	std::ios::sync_with_stdio(false);
	std::cin >> n >> m >> a >> b >> c;
	Matrix input(n, n);

	for (int i = 0, x, y; i < m; i++) {
		std::cin >> x >> y;
		input.a[--x][--y] = true;
	}
	Matrix ta{input};
	Matrix tb{input};
	Matrix tc{input};
	Matrix tar{input};
	tar |= quick(input, a);
	tar |= quick(input, b);
	tar |= quick(input, c);
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			map[i][j] = tar.a[i][j];

	/*
	Matrix tt(n, n);
	tt = tar;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++)
			std::cout << tt.a[i][j] << ' ';
		std::cout << '\n';
	}
	*/
	vis[n - 1] = true;
	if (judge_circle(0)) {
		std::cout << "IMPOSSIBLE\n";
		return 0;
	} else {
		for (int i = 0; i < n; i++) dis[i] = -inf, vis[i] = false;
		for (int i = 0; i < n; i++)
			for (int j = 0; j < n; j++)
				if (map[i][j]) indegree[j]++;
		dis[0] = 0;
		std::queue<int> q;
		for (int i = 0; i < n; i++)
			if (!indegree[i]) {
				q.push(i);
				vis[i] = true;
			}
		while (!q.empty()) {
			int now = q.front(); q.pop();
			for (int i = 0; i < n; i++) {
				if (!map[now][i]) continue;
				dis[i] = std::max(dis[i], dis[now] + 1);
				indegree[i]--;
				if (!vis[i]) q.push(i);
			}
		}
		if (dis[n - 1] < 0) { std::cout << "IMPOSSIBLE\n"; return 0; }
		std::cout << dis[n - 1] << '\n';
	}
}

